package com.bdqn.hospital.controller;

import com.bdqn.hospital.pojo.ChargeRecords;
import com.bdqn.hospital.service.ChargeRecordsService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @version : 1.0
 * @Author :guogd
 * @createTime: 2023/03/01 14:34
 * @Description: com.bdqn.hospital.controller
 */
@Controller
@RequestMapping("charge")
public class ChargeRecordsController {
    /**
     * 收费记录Controller
     */

    @Autowired
    private ChargeRecordsService chargeRecordsService;

    //跳转收银员页面
    @RequestMapping("goToPay")
    public String goToPay(){
        return "pay";
    }


    //获取收费记录，并跳转收费记录的页面
    @RequestMapping("getAllChargeRecords")
    public String getAllChargeRecords(Model model,@RequestParam(defaultValue = "1",required = false)Integer curPage){
        List<ChargeRecords> chargeRecordsList = chargeRecordsService.getAllChargeRecords();
        PageHelper.startPage(curPage,6);
        PageInfo<ChargeRecords> pageInfo=new PageInfo<>(chargeRecordsList);
        model.addAttribute("chargeRecordsList",pageInfo);
        return "chargeRecords";
    }
}
